import axios from "axios";

const instance = axios.create({
  baseURL: "/api",
});

instance.interceptors.request.use(
  function (config) {
    let token = localStorage.getItem("token");
    // console.log(token);
    
    if (token) {
      if (config.headers) {
        config.headers["Authorization"] = token;
      }
    }
    return config;
  },
  function (error) {
    return Promise.reject(error);
  }
);

axios.interceptors.response.use(
  function (response) {
    return response;
  },
  function (error) {
    return Promise.reject(error);
  }
);
export default instance;
